@extends('backstage.layout.master')
@section('title', '添加轮播图')
@section('style')
@stop
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="backstage/home">主页</a>
            </li>
            <li>
                添加轮播图
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        添加轮播图
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form id="myform" class="form-horizontal" role="form" action="backstage/carousels/add" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                            <div class="form-group ">
                                <label class="col-sm-4 control-label no-padding-right"> 类型选择 </label>
                                <div class="col-sm-4">
                                        <select name="carousel_type" class="form-control" id="form-field-select-1">
                                            <option @if(old('carousel_type') == 1)selected @endif value="1">产品详情</option>
                                            <option @if(old('carousel_type') == 2)selected @endif value="2">产品模板</option>
                                            <option @if(old('carousel_type') == 3)selected @endif value="3">外链</option>
                                            <option @if(old('carousel_type') == 4)selected @endif value="4">帮助系统</option>
                                        </select>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline">{{$errors->first('carousel_type')}} </div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group resource_form {{$errors->first('resource_id')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right"> 资源ID </label>
                                <div class="col-sm-4">
                                    <input type="text" name="resource_id" value="{{old('resource_id')}}" id="resource_id" placeholder="资源ID"
                                           class="width-100">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline">{{$errors->first('resource_id')}} </div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group url_form {{$errors->first('url')!=""?'has-error':''}}" style="display:none;">
                                <label class="col-sm-4 control-label no-padding-right"> 外链 </label>

                                <div class="col-sm-4">
                                    <input type="text" name="url" id="url" class="width-100 url" value="{{old('url')}}" placeholder="外链"
                                    >
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline">{{$errors->first('url')}} </div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('carousel_image')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right" for="form-field-1">
                                    轮播图 </label>

                                <div class="col-sm-4">
                                    <input type="file" id="carousel_image" name="carousel_image" placeholder="轮播图">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline">{{$errors->first('carousel_image')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('begin')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right">开始时间</label>
                                <div class="col-sm-4">
                                    <input type="date"  id="begin" name="begin" class="form-control datepicker" value="{{old("begin")}}"/>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('begin')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group {{$errors->first('end')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right">结束时间</label>
                                <div class="col-sm-4">
                                    <input type="date"  id="end" name="end" class="form-control datepicker" value="{{old("end")}}"/>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> {{$errors->first('end')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-5 col-md-7">
                                    <button class="btn btn-info" type="submit">
                                        <i class="icon-ok bigger-110"></i>
                                        保存
                                    </button>

                                    &nbsp; &nbsp; &nbsp;
                                    <button class="btn" type="reset">
                                        <i class="icon-undo bigger-110"></i>
                                        重置
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div><!-- /.col -->
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
    <script type="text/javascript">
        var showFlag = 0;
        var _token = '{{csrf_token()}}';
        $(function () {
            show();
            $("#begin").change(function() {
                $("#end").attr("min", $(this).val());
            });
            $("#end").change(function() {
                $("#begin").attr("max", $(this).val());
            });
            $('#carousel_image').ace_file_input({
                no_file: '还未选择轮播图',
                btn_choose: '选择',
                btn_change: '重新选择',
                droppable: false,
                onchange: null,
                thumbnail: true
            });
            $("#form-field-select-1").change(function(){
                show();
            });
        });
        function show(){
            var $flag = $("#form-field-select-1").val();
            if($flag == 1 || $flag == 2){
                $(".resource_form").show();
                $(".url_form").hide();
            }else if($flag == 3){
                $(".resource_form").hide();
                $(".url_form").show();
            }else if($flag == 4){
                $(".resource_form").hide();
                $(".url_form").hide();
            }
        }
    </script>
@stop